package com.briup.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.demo.bean.XcdComment;
import com.briup.demo.common.Response;
import com.briup.demo.service.XcdCommentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "评论信息管理")
@RestController
@RequestMapping("/comment")
public class XcdCommentController {

	@Autowired
	private XcdCommentService commentService;
	
	@ApiOperation(value = "显示所有评论")
	@GetMapping("/selectAll")
	public Response<List<XcdComment>> selectAll(){
		List<XcdComment> list = commentService.selectAll();
		return Response.ok(list);
	}
	
	@ApiOperation(value = "评论编号查找评论信息")
	@GetMapping("/selectById")
	public Response<XcdComment> selectById(String id){
		XcdComment xc = commentService.selectById(id);
		return Response.ok(xc);
	}
	
	@ApiOperation(value = "删除评论信息")
	@DeleteMapping("/deleteById")
	public Response<String> deleteById(String id){
		int num = commentService.deleteById(id);
		if(num==0) {
			return Response.ok("不存在此评论");
		}
		return Response.ok("删除成功");
	}
	
	@ApiOperation(value = "批量删除评论信息")
	@DeleteMapping("/deleteByIds")
	public Response<String> deleteByIds(String[] ids){
		int num = commentService.deleteByIds(ids);
		if(num==0) {
			return Response.ok("不存在这些评论");
		}else {
			return Response.ok("删除成功"+num+"条信息");
		}
	}
}






